package egress

import (
	v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/runtime"
	"k8s.io/apimachinery/pkg/runtime/schema"
)

var Schema = schema.GroupVersionResource{
	Group:    "king.io",
	Version:  "v1",
	Resource: "egresses",
}

var SchemeGroupVersion = schema.GroupVersion{Group: "king.io", Version: "v1"}

var (
	SchemaBuilder      = runtime.NewSchemeBuilder(addKnownTypes)
	localSchemeBuilder = &SchemaBuilder
	AddToScheme        = SchemaBuilder.AddToScheme
)

type MeshStartStatus string

const (
	BUILD MeshStartStatus = "build"
	READY                 = "ready"
	FAIL                  = "fail"
)

type Egress struct {
	v1.TypeMeta   `json:",inline"`
	v1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
	Spec          EgressSpec   `json:"spec,omitempty"`
	Status        EgressStatus `json:"status,omitempty"`
}

func (m *Egress) DeepCopyObject() runtime.Object {
	if c := m.DeepCopy(); c != nil {
		return c
	}
	return nil
}

func (in *Egress) DeepCopy() *Egress {
	if in == nil {
		return nil
	}
	out := new(Egress)
	in.DeepCopyInto(out)
	return out
}

func (in *Egress) DeepCopyInto(out *Egress) {
	*out = *in
	out.TypeMeta = in.TypeMeta
	in.Spec.DeepCopyInto(&out.Spec)
	in.Status.DeepCopyInto(&out.Status)
	return
}

type EgressSpec struct {
	Resources []string `json:"resources"`
}

func (in *EgressSpec) DeepCopyInto(out *EgressSpec) {
	*out = *in
	if in.Resources != nil {
		in, out := &in.Resources, &out.Resources
		*out = make([]string, len(*in))
		for i := range *in {
			(*in)[i] = (*out)[i]
		}
	}
	return
}

func (in *EgressSpec) DeepCopy() *EgressSpec {
	if in == nil {
		return nil
	}
	out := new(EgressSpec)
	in.DeepCopyInto(out)
	return out
}

type EgressStatus struct {
}

func (in *EgressStatus) DeepCopyInto(out *EgressStatus) {
	*out = *in
	return
}

func (in *EgressStatus) DeepCopy() *EgressStatus {
	if in == nil {
		return nil
	}
	out := new(EgressStatus)
	in.DeepCopyInto(out)
	return out
}

func addKnownTypes(scheme *runtime.Scheme) error {
	scheme.AddKnownTypes(SchemeGroupVersion,
		&Egress{},
	)

	v1.AddToGroupVersion(scheme, SchemeGroupVersion)
	return nil
}
